package com.xcw.test;

import java.util.Arrays;
import java.util.function.Supplier;

/**
 * @Author bhx
 * @Date 2022/8/9 2:39
 * @Description TODO
 */
public class SupplierDemo {
    public static String getString(Supplier<String> sup){
            return sup.get();
    }
    public static Integer getInteger(Supplier<Integer> sup){
        return sup.get();
    }

    public static void main(String[] args) {
//        String string2 = getString(() -> {
//            return "虎哥";
//        });
//        System.out.println(string2);
//
//        String string = getString(() -> "huge");
//        System.out.println(string);

        int[] ints = {1,22,34,222,54,21};
        System.out.println(getInteger(() -> {
            int max = ints[0];
            for (int i : ints) {
                if (i > max) {
                    max = i;
                }
            }
            return max;
        }));
    }

}
